<html>
<head>
<script>
function setFormat(cmd,userUI,value) {
	editor.setFormat(cmd,userUI,value);
}

function setFontName(element) {
	setFormat("FontName",false,element.value);
}

function setFontSize(element) {
	setFormat("FontSize",false,element.value);
}

function setColor(element) {
	setFormat("forecolor",false,element.value);
}

function format(cmd) {
	setFormat(cmd);
}

function putImage() {
	setFormat("insertimage",false,"http://smg.stopklatka.pl/buffy/Buffy.jpg");
}

function align(dir) {
	setFormat("justify"+dir,false,null);
}
</script>
</head>
<body bgcolor="white">
<script>
function generateSelect(functionName,optionsList) {
	var str = "<select onClick=\""+functionName+"(this);\">";
	var options = optionsList.split(",");
	for (var i=0; i<options.length; i++) {
		var value=options[i];
		var text=options[i];
		if (options[i].indexOf("|")!=-1) {
			value = options[i].split("|")[0];
			text = options[i].split("|")[1];
		}
		str+="<option value=\""+value+"\">"+text+"</option>";
	}
	str+="</select>";
	return str;
}
function generateFontSelect(functionName) {
	var avFonts = "Arial,Courier,Times New Roman";
	return generateSelect(functionName,avFonts);
}
function generateColorSelect(functionName) {
	var avColors = "black,white,red,green,blue,yellow,gray";
	return generateSelect(functionName,avColors);
}
function generateFontSizeSelect(functionName) {
	var avSizes = "-2|smallest,-1|small,+0|normal,+1|large,+2|largest";
	return generateSelect(functionName,avSizes);
}
</script>

<script>
document.write(generateFontSelect("setFontName"));
document.write(generateFontSizeSelect("setFontSize"));
document.write(generateColorSelect("setColor"));
</script>
<button onClick="format('bold');"><b>B</b></button>
<button onClick="format('italic');"><i>I</i></button>
<button onClick="format('underline');"><u>U</u></button>
Align:
<button onClick="align('left');">Left</button>
<button onClick="align('right');">Right</button>
<button onClick="align('center');">Center</button>
<button onClick="align('full');">Justify</button>
<button onClick="putImage();">Put Image</button>
<br/>
<iframe width="100%" height="100%" src="page.html" id="editor" name="editor"/>


</body>
</html>